import Vue from 'vue'
import Router from 'vue-router'
import register from './views/register.vue'

Vue.use(Router)

export default new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [{
    path: '/',
    redirect: '/footernav'
  },
  {
    path: '/register',
    name: 'register',
    component: register
  },
  {
    path: '/login',
    name: 'login',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    // 路由懒加载
    component: () => import('./views/login.vue')
  },
  {
    path: '/footernav',
    name: 'footernav',
    component: () => import('./views/footerNav.vue'),
    children: [{
      path: '',
      redirect: 'index'
    },
    {
      path: 'index',
      name: 'index',
      component: () => import('./views/index.vue')
    },
    {
      path: 'list',
      name: 'list',
      component: () => import('./views/List.vue')
    },
    {
      path: 'cart',
      name: 'cart',
      component: () => import('./views/Cart.vue'),
      meta: {
        requiresAuth: true
      }
    },
    {
      path: 'search',
      name: 'search',
      component: () => import('./views/Search.vue')
    },
    {
      path: 'mine',
      name: 'mine',
      component: () => import('./views/Mine.vue'),
      meta: {
        requiresAuth: true
      }
    }
    ]
  }
  ]
})
